package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.model.Cuser;
import com.zr.service.ShoScopService;

import net.sf.json.JSONNull;
import net.sf.json.JSONObject;
@Controller
@Scope(value="prototype")
public class ShoScopAction implements ServletResponseAware,SessionAware{
	
	private Map<String,Object>session;
	private HttpServletResponse resp;
	
	@Override
	public void setSession(Map<String, Object> arg0) {
		// TODO Auto-generated method stub
		this.session=arg0;
	}
	
	
	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		this.resp=arg0;
	}
	
	@Resource
	private ShoScopService shoscopserviceimpl;
public void shoScop(){
	resp.setCharacterEncoding("utf8");
	try {
		PrintWriter pw=resp.getWriter();
		Cuser cu=(Cuser) session.get("cuser");
		String uname=cu.getUname();
			JSONObject jo=shoscopserviceimpl.getStation(uname);
			
			//if(jo.get("disid")==null){
				//System.out.println(11);
				//req.getRequestDispatcher("sorry.jsp").forward(req, resp);;
			//	resp.sendRedirect("sorry.jsp");
			//}else{
			//	System.out.println(22);
			pw.write(jo.toString());
			//}
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
		
	}


}
